<%-- 
    Document   : user
    Created on : 2018-11-1, 12:26:32
    Author     : yaohk
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>用户管理</title>
        <%@include file="/WEB-INF/jspf/layui/top_layui.jspf" %>
        <style type="text/css">
            .title{
                margin-bottom: 5px; 
                background: #fafafa; 
                border-bottom: 1px solid #ddd;
                padding-left: 5px; 
                height: 30px;
                line-height: 30px;
                font-size: 14px;
                font-weight: 700;
                color: #999;
            }
            .layui-form-item{
                margin: 0px 0px 0px 5px;
            }
            #user_details .layui-form-item .layui-input-inline{
                width: 140px;
            }
            .layui-treeSelect .ztree  *{
                font-size: 12px !important;
            }
            .layui-treeSelect .ztree  li span{
                top: 3px !important;
            }
        </style>
    </head>
    <body>
        <script type="text/javascript">
            $("body").mask({
                maskMsg: '<div class="loading_text"><img src="${contextPath}/resources/images/loading_2.gif"/><span>正在初始化，请稍后...</span></div>',
                opacity: 1
            });
            $(function () {
                $("body").mask('hide');
            });
        </script>
        <!--搜素框-->
        <div class="layui-row layui-col-space10" style="margin: 6px 0px 0px 5px;">
            <div class="layui-col-md2">
                <input type="text" id="user_account" name="user_account" placeholder="请输入用户账户" class="layui-input"/>
                <!--<a class="" id="search_user_account" style="display: inline-block;width: 20px;height: 36px;line-height: 36px;"><i class="layui-icon layui-icon-search"></i></a>-->
                <a class="" id="search_user_account" style="display: inline-block;width: 20px;height: 36px;line-height: 36px; position: absolute;top:6px; right:6px;"><i class="layui-icon layui-icon-search"></i></a>
            </div>
            <div class="layui-col-md2">
                <input type="text" id="user_name" name="user_name" placeholder="请输入用户姓名" class="layui-input"/>
                <!--<a class="" id="search_user_name" style="display: inline-block;width: 20px;height: 36px;line-height: 36px;"><i class="layui-icon layui-icon-search"></i></a>-->
                <a class="" id="search_user_name" style="display: inline-block;width: 20px;height: 36px;line-height: 36px; position: absolute;top:6px; right:6px;"><i class="layui-icon layui-icon-search"></i></a>
            </div>
            <div class="layui-col-md2">
                <div class="layui-form" lay-filter="*">
                    <select name="user_status" id="user_status" lay-filter="user_status">
                        <option value="" >请选择状态</option>
                        <option value="0">激活</option>
                        <option value="1">冻结</option>
                    </select>
                </div>
            </div>
            <div class="layui-col-md3">
                <!--<button class="layui-btn layui-btn-sm" id="reset"><i class="layui-icon layui-icon-refresh"></i>重置</button>-->
                <button class="layui-btn layui-btn-sm" id="reset" style="height: 36px;"><i class="layui-icon layui-icon-refresh"></i>&nbsp;重&nbsp;&nbsp;置</button>
                <shiro:hasPermission name="user:add:*">
                    <button class="layui-btn layui-btn-sm" lay-filter="formDemo" id="add_user" style="height: 36px;"><i class="layui-icon">&#xe608;</i>添加用户</button>
                </shiro:hasPermission>
            </div>
        </div>

        <!--数据表格-->
        <table id="user" lay-filter="user" class=""></table>

        <!--增加/修改用户 display: none;  -->
        <form class="layui-form" id="user_details" lay-filter="details" style="border: 1px solid #ddd;margin-bottom: 10px; display: none;">
            <div class="title" style=""><i class="layui-icon layui-icon-tabs"></i> &nbsp;基本信息</div>
            <div style="height: 130px;">
                <input type='hidden' name='id' id="userId"/>
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">用户账户</label>
                        <div class="layui-input-inline">
                            <input type="text" id="account" name="account" placeholder="请输入用户账户" lay-verify="required" autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name" name="name" placeholder="请输入用户姓名" lay-verify="required" autocomplete="off" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别</label>
                        <div class="layui-input-inline">
                            <select name="sex" lay-verify="" style="">
                                <option value="0">男</option>
                                <option value="1">女</option>
                            </select> 
                            <!--<input type="checkbox" name="uSex" id="uSex" lay-skin="switch" lay-filter="userSex" lay-text="男|女" checked/>-->
                            <!--<input type="hidden" name="sex" id="sex" value="0"/>-->
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">证件类型</label>
                        <div class="layui-input-inline">
                            <select name="certType" lay-verify="" lay-filter="certType">
                                <option value="1" selected>身份证</option>
                                <option value="2">军官证</option>
                                <option value="3">护照</option>
                                <option value="4">其他</option>
                            </select>     
                        </div>
                    </div>
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">证件号码</label>
                        <div class="layui-input-inline">
                            <input type="text" id="certNo" name="certNo" autocomplete="off" class="layui-input" lay-verify="certNo"/>
                        </div>
                    </div>
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">电子邮箱</label>
                        <div class="layui-input-inline">
                            <input type="text" id="emial" name="emial" autocomplete="off" class="layui-input" lay-verify="email"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">固定电话</label>
                        <div class="layui-input-inline">
                            <input type="text" id="tel" name="tel" placeholder="区号-电话号码" autocomplete="off" class="layui-input" lay-verify="tel"/>
                        </div>
                    </div>
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">移动电话</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mobile" name="mobile" autocomplete="off" class="layui-input" lay-verify="phone" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="uStatus" id="uStatus" lay-skin="switch" lay-filter="userStatus" lay-text="激活|冻结" checked />
                            <input type="hidden" name="status" id="status" value="0"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="title" style="border-top: 1px solid #ddd;"><i class="layui-icon layui-icon-tabs"></i>&nbsp;基础信息</div>
            <div style="height: 50px;">
                <div class="layui-form-item">
                    <div class="layui-input-block dept" style="margin-left: 0px;">
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">所属部门</label>
                        <div class="layui-input-inline">
                            <input type="text" name="deptId" id="deptId" lay-filter="treeSelect" lay-verify="required" style="height: 20px;">
                        </div>
                    </div>
                </div>
            </div>
            <div class="title" style="border-top: 1px solid #ddd;"><i class="layui-icon layui-icon-tabs"></i>&nbsp;角色列表</div>
            <div style="min-height: 270px;">
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="padding: 9px 5px; width: auto;">角色名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="role_name" name="role_name" placeholder="请输入关键字" class="layui-input"/>
                        </div>
                        <div class="layui-input-inline" style="position: absolute; right: 2px; width: 20px">
                            <a class="" id="search_role_name" style="display: inline-block;width: 20px;height: 36px;line-height: 36px;"><i class="layui-icon layui-icon-search"></i></a>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="getCheckData" id="check_role">查看所选角色</button>
                        <!--<button type="button" class="layui-btn layui-btn-sm" id="">查看所选角色</button>-->
                        <button type="button" class="layui-btn layui-btn-sm" id="reload">重新加载</button>
                    </div>
                </div>

                <!--数据表格-->
                <table id="role" lay-filter="role" class=""></table>
            </div>
            <button type="button" class="layui-btn layui-btn-sm" lay-submit lay_filter="*" id="add" style="display: none;">添加</button>
        </div>
    </form>




    <script type="text/javascript">
        layui.config({
            base: '${contextPath}/layui/'
        }).extend({
            treeSelect: 'treeSelect'
        }).use(['table', 'form', 'layer', 'treeSelect', 'laytpl'], function () {
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;
            var treeSelect = layui.treeSelect;
            var laytpl = layui.laytpl;
            var openContent;
            var tableIns = table.render({
                elem: '#user',
//                    height: 490,
                url: '${contextPath}/user/list/dataL.json',
                page: {//支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip', 'refresh'], //自定义分页布局
                    limits: [5, 10, 20, 30, 50],
                    groups: 5,
                    first: false, //不显示首页和尾页
                    last: false
                },
                //                    page:true,
                text: {none: '暂无相关数据！'}, //自定义文本，如空数据时的异常提示等。
                even: true, //隔行背景
//                    size: 'sm',
                autoSort: false,
                cols: [[//
                        {type: 'numbers', fixed: 'left'},
                        {field: 'open', title: '操作', fixed: 'left', align: 'center',
                            templet: function (d) {
                                openContent = '';
        <shiro:hasPermission name="user:detail:*">
                                openContent += '<a href="#" lay-event="showDetails" title="查看详情"><i class="layui-icon layui-icon-table" ></i></a>&nbsp;&nbsp;&nbsp;&nbsp;';
        </shiro:hasPermission>
        <shiro:hasPermission name="user:modify:*">
                                openContent += '<a href="#" lay-event="edit" title="编辑"><i class="layui-icon layui-icon-edit"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;';
        </shiro:hasPermission>
        <shiro:hasPermission name="user:delete:*">
                                openContent += '<a href="#" lay-event="delete" title="删除"><i class="layui-icon layui-icon-delete"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;';
        </shiro:hasPermission>
        <shiro:hasPermission name="user:modify:*">
                                if (d.status === 0) {
                                    openContent += '<a href="#" lay-event="toLock" title="冻结"><i class="layui-icon layui-icon-password"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;';
                                } else {
                                    openContent += '<a href="#" lay-event="toLock" title="激活"><i class="layui-icon layui-icon-auz"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;';
                                }
        </shiro:hasPermission>
        <shiro:hasPermission name="user:resetpwd:*">
                                openContent += '<a href="#" lay-event="resetPwd" title="重置密码"><i class="layui-icon layui-icon-tips"></i></a>';
        </shiro:hasPermission>
                                return openContent;
                            },
                            toolbar: openContent},
                        {field: 'account', title: '用户账户', sort: true, align: 'center'},
                        {field: 'name', title: '姓名', sort: true, align: 'center'},
                        {field: 'deptName', title: '所属部门', sort: true, align: 'center'},
                        {field: 'status', title: '状态', width: 230, sort: true, align: 'center',
                            templet: function (d) {
                                if (d.status === 0) {
                                    return '激活';
                                } else {
                                    return '<span style="color: #f00;">冻结</span>';
                                }
                            }
                        }
                    ]]
            });
            var tableRole = table.render({
                id: 'role',
                elem: '#role',
//                    height: 200,
//                    url: '${contextPath}/user/list/userRole.json?id=1', //数据接口,
                text: {none: '暂无相关数据！'}, //自定义文本，如空数据时的异常提示等。
//                    page: true,
                even: true, //隔行背景
                size: 'sm',
                autoSort: false, //禁用前端自动排序。注意：该参数为 layui 2.4.4 新增
                cols: [[//
                        {type: 'checkbox', field: ''},
                        {type: 'numbers'},
                        {field: 'name', title: '角色名称', sort: true, align: 'center', width: 200},
                        {field: 'remark', title: '角色描述', align: 'center', width: 300}
                    ]]
            });
            treeSelect.render({
                elem: '#deptId',
                data: '${contextPath}/dept/list/deptTreeLayui.json',
                type: 'get',
                placeholder: '请选择部门名称',
                size: 'sm',
                //                    search: false, // 是否开启搜索功能：true/false，默认false
                // 点击回调
                click: function (data) {
                    $('#deptId').attr('value', data.current.id);
                },
                // 加载完成后的回调函数
                success: function (data) {

                    //                选中节点，根据id筛选
                    //                treeSelect.checkNode('tree', 3);
                    //                获取zTree对象，可以调用zTree方法
                    //                var treeObj = treeSelect.zTree('tree');
                    //                console.log(treeObj);
                    //                刷新树结构
                    treeSelect.refresh('treeSelect');
                }
            });
            //重载角色
            $('#reload').click(function () {
                $('#role_name').val('');
                tableRole.reload({where: {}});
            });
            //                查看所选角色LAY_CHECKED
            $('#check_role').click(function () {
                var roleId = new Array();
                var checkStatus = table.checkStatus('role').data;
//                    console.log(checkStatus);
                for (var item in checkStatus) {
                    roleId[item] = checkStatus[item].name;
                }
                layer.alert('当前选择的角色为：' + roleId.join(), {title: '友情提示'});
            });
//                角色搜素
            $('#search_role_name').click(function () {
                tableRole.reload({
                    where: {
                        name: $('#role_name').val()
                    }
                });
            });
            $('#role_name').bind('keypress', function (even) {
                if (even.keyCode == 13) {
                    tableRole.reload({
                        where: {
                            name: $('#role_name').val()
                        }
                    });
                }
            });
//                监听操作栏
            table.on('tool(user)', function (obj) {
                if (obj.event === 'showDetails') {
                    showDetails(obj.data);
                } else if (obj.event === 'edit') {
                    edit(obj.data);
                } else if (obj.event === 'delete') {
                    Delete(obj.data);
                } else if (obj.event === 'toLock') {
                    toLock(obj.data);
                } else if (obj.event === 'resetPwd') {
                    resetPwd(obj.data);
                }
            });
            //监听行双击事件
            table.on('rowDouble(user)', function (obj) {
                showDetails(obj.data);
            });
            //监听排序事件
            table.on('sort(user)', function (obj) {
                tableIns.reload({
                    initSort: obj, //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                    where: {//请求参数
                        account: $('#user_account').val(),
                        name: $('#user_name').val(),
                        status: $('#user_status').val(),
                        sort: obj.field, //排序字段
                        order: obj.type //排序方式 
                    }
                });
            });
            //添加用户
            $('#add_user').click(function () {
                $.ajax({
                    url: "${contextPath}/user/add/ui.json",
                    success: function () {
                        formValue('');
                        tableRole.reload({url: '${contextPath}/user/list/userRole.json?id=0&status=0'}); //获取所有激活的角色
//                    $('#add').show();
//                    $('#mod').hide();
                        layer.open({
                            type: 1,
                            title: '添加用户信息',
                            area: ['780px', '500px'],
                            content: $('#user_details'),
                            maxmin: true,
                            btn: ['添加', '取消'],
                            yes: function () {
                                $('#add').click(); //触发表单验证
                                if (verify)
                                    addOrUpdate('${contextPath}/user/add/user.json');
                            }
                        });
                    }
                });
            });
//                监听开关
//            form.on('switch(userSex)', function (data) {
//                $('#sex').val(data.elem.checked == true ? 0 : 1); //开关是否开启，true或者false
//            });
            form.on('switch(userStatus)', function (data) {
                $('#status').val(data.elem.checked == true ? 0 : 1);
            });
            var certType = "1";//默认证件类型为身份证
            form.on('select(certType)', function (data) {
                certType = data.value;
            });
            var verify = false;
            form.verify({
                required: function (value) {
                    if (/^\S+$/.test(value)) {
                        verify = true;
                    } else {
                        verify = false;
                        return '必填项不能为空';
                    }
                },
                phone: function (value) {
                    if (/(^\s{0}$)|(^1\d{10}$)/.test(value)) {
                        verify = true;
                    } else {
                        verify = false;
                        return "请输入正确的电话号码";
                    }
                },
                tel: function (value) {
                    if (/(^\s{0}$)|(^0\d{2}-\d{8}$)|(^0\d{3}-\d{7}$)/.test(value)) {
                        verify = true;
                    } else {
                        verify = false;
                        return "请输入正确的固定电话号码";
                    }
                },
                email: function (value) {
                    if (/(^\s{0}$)|(^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$)/.test(value)) {
                        verify = true;
                    } else {
                        verify = false;
                        return "邮箱格式不正确";
                    }
                },
                certNo: function (value, item) {
                    if (/^\s{0}$/.test(value)) {//验证为空
                        verify = true;
                    } else if (/(^\d{15}$)|(^\d{17}(x|X|\d)$)/.test(value) && certType === "1") {//验证身份证号
                        verify = true;
                    } else if (/^\d{8}$/.test(value) && certType === "2") {//验证军官证
                        verify = true;
                    } else if (/^[DGPS]\d{8}$/.test(value) && certType === "3") {//验证护照
                        verify = true;
                    } else if (/^\d+$/.test(value) && certType === "4") {//验证其他
                        verify = true;
                    } else {
                        verify = false;
                        return "证件号码格式不正确";
                    }
                }
            });
            function addOrUpdate(url) {
//                    if ($('#account').val() == '') {
//                        layer.tips('请输入用户账户', '#account');
//                        return false;
//                    }
//                    if ($('#name').val() == '') {
//                        layer.tips('请输入用户姓名', '#name');
//                        return false;
//                    }
//                    if ($('#deptId').val() == '') {
//                        layer.tips('请选择所属部门', '#dept');
//                        return false;
//                    }
                var checkStatus = table.checkStatus('role').data;
                if (checkStatus.length == 0) {
                    layer.msg('请选择角色', {time: 1500});
                    return false;
                }
                for (var item in checkStatus) {
                    $("#user_details").append("<input type='hidden' name='roleId' value='" + checkStatus[item].id + "' />")
                }
                var upOptions = {
                    url: url,
                    type: 'post',
//                        dataType: "json",
                    beforeSumbit: function () {
                    },
                    success: function (data) {
                        if (data.ifAdd) {
                            layer.closeAll();
                            layer.msg('添加用户成功！');
                            tableIns.reload();
                        } else if (data.ifUpdate) {
                            layer.closeAll();
                            layer.msg('修改用户成功！');
                            tableIns.reload();
                        } else {
                            layer.msg('操作失败！' + data.msg);
                        }
                    },
                    complete: function () {
                        $("#user_details input[name='roleId']").remove(); //清空角色id隐藏表单域
                    }
                };
                $('#user_details').ajaxSubmit(upOptions);
            }

            function formValue(data) {
                $('.dept .layui-unselect').attr('value', data.deptName); //设置上级部门的默认值
                form.val('details', {
                    'id': data.id,
                    'account': data.account,
                    'name': data.name,
                    'sex': data.sex,
//                    'uSex': data.sex === 1 ? false : true,
                    'deptId': data.deptId,
                    'certType': data.certType,
                    'certNo': data.certNo,
                    'tel': data.tel,
                    'mobile': data.mobile,
                    'email': data.email,
                    'status': data.status,
                    'uStatus': data.status === 1 ? false : true
                });
            }

//                查看用户详情
            function showDetails(data) {
                $.ajax({
                    url: "${contextPath}/user/detail/ui.json",
                    success: function () {
                        tableRole.reload({url: '${contextPath}/user/list/userRole.json?id=' + data.id});
                        formValue(data);
                        layer.open({
                            type: 1,
                            title: '查看用户信息',
                            area: ['780px', '500px'],
                            content: $('#user_details'),
                            maxmin: true,
                            btn: ['取消']
                        });
                    }
                });
            }
//                编辑用户信息
            function edit(data) {
                $.ajax({
                    url: "${contextPath}/user/modify/ui.json",
                    success: function () {
                        tableRole.reload({url: '${contextPath}/user/list/userRole.json?id=' + data.id});
                        formValue(data);
                        layer.open({
                            type: 1,
                            title: '编辑用户信息',
                            area: ['780px', '500px'],
                            content: $('#user_details'),
                            maxmin: true,
                            btn: ['保存', '取消'],
                            yes: function () {
                                $('#add').click();
                                if (verify)
                                    addOrUpdate('${contextPath}/user/modify/user.json');
                            }
                        });
                    }
                });
            }
//                删除用户
            function Delete(data) {
                $.ajax({
                    url: "${contextPath}/user/delete/ui.json",
                    success: function () {
                        layer.confirm('您确定要删除用户账户为【' + data.name + '】的用户吗？', {title: '友情提示', icon: 3}, function (index) {
                            $.ajax({
                                type: "post",
                                url: '${contextPath}/user/delete.json?userId=' + data.id,
                                success: function () {
                                    layer.msg('删除成功', {icon: 6});
                                    tableIns.reload();
                                }
                            });
                        });
                    }
                });
            }

            //                冻结激活用户
            function toLock(data) {
                $.ajax({
                    url: "${contextPath}/user/modify/ui.json",
                    success: function () {
                        var str = '激活', status = 'unlock';
                        if (data.status == '0') {
                            str = '冻结';
                            status = 'lock';
                        }
                        layer.confirm('您确定要' + str + '用户账户为【' + data.name + '】的用户吗？', {title: '友情提示', icon: 3}, function (index) {
                            $.ajax({
                                type: "post",
                                url: '${contextPath}/user/modify/lockUser.json?userId=' + data.id + '&action=' + status,
                                success: function () {
                                    layer.msg(str + '成功', {icon: 6});
                                    tableIns.reload();
                                }
                            });
                        });
                    }
                });
            }

            //                重置密码
            function resetPwd(data) {
                $.ajax({
                    url: "${contextPath}/user/resetpwd/ui.json",
                    success: function () {
                        layer.confirm('你确定要为用户账户为【' + data.name + '】重置密码吗？', {title: '友情提示', icon: 3}, function () {
                            $.ajax({
                                type: "post",
                                url: "${contextPath}/user/resetpwd.json?userId=" + data.id,
                                success: function () {
                                    layer.msg('重置密码成功');
                                }
                            });
                        });
                    }
                });
            }
            //用户账户搜索
            $('#search_user_account').click(function () {
                $('#user_name').val('');
                form.val('*', {
//                        'user_name': '',
                    'user_status': ''
                });
                tableIns.reload({
                    where: {
                        account: $('#user_account').val()
                    }
                });
            });
            $('#user_account').bind('keypress', function (even) {
                $('#user_name').val('');
                form.val('*', {
//                        'user_name': '',
                    'user_status': ''
                });
                if (even.keyCode == 13) {
                    tableIns.reload({
                        where: {
                            account: $('#user_account').val()
                        }
                    });
                }
            });
            //用户姓名搜索
            $('#search_user_name').click(function () {
                $('#user_account').val('');
                form.val('*', {
//                        'user_account': '',
                    'user_status': ''
                });
                tableIns.reload({
                    where: {
                        name: $('#user_name').val()
                    }
                });
            });
            $('#user_name').bind('keypress', function (even) {
                $('#user_account').val('');
                form.val('*', {
//                        'user_account': '',
                    'user_status': ''
                });
                if (even.keyCode == 13) {
                    tableIns.reload({
                        where: {
                            name: $('#user_name').val()
                        }
                    });
                }
            });
            //状态搜索
            form.on('select(user_status)', function () {
                $('#user_account').val('');
                $('#user_name').val('');
//                    form.val('search', {
//                        'user_account': '',
//                        'user_name': ''
//                    });
                tableIns.reload({
                    where: {
                        status: $('#user_status').val()
                    }
                });
            });
            //重置搜索条件
            $('#reset').click(function () {
                $('#user_account').val('');
                $('#user_name').val('');
                form.val('*', {
//                        'user_account': '',
//                        'user_name': '',
                    'user_status': ''
                });
                tableIns.reload({where: {}});
            });
        });
        $(document).ajaxError(new jQueryAjaxErrorHandler());
    </script>
</body>
</html>
